<template>
  <div id="rzList">
    <el-card class="box-card" style="height: 100%">
      <div slot="header" class="clearfix">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-input placeholder="请输入操作人员名称查询" size="medium" v-model="queryInfo.userName" class="input-with-select" clearable @clear="getRiZhiList">
              <el-button size="medium"  type="goon" round slot="append" icon="el-icon-search" @click="getRiZhiList" ></el-button>
            </el-input>
          </el-col>
          <el-col :span="8">
            <el-select size="medium" v-model="queryInfo.operationName"  clearable placeholder="请选择操作类型" @change="getRiZhiList">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-col>
        </el-row>
      </div>
      <div class="ziYuanTable">
      <el-table
        :data="riZhiData"
        border
        height="100%"
        style="width: 100%">
        <el-table-column
          type="index"
          label="#"
          min-width="2%"
        >
          <template v-slot="scope">
            {{ (queryInfo.pageNumber-1) * queryInfo.pageSize+ scope.$index + 1}}
          </template>
        </el-table-column>
        <el-table-column
          prop="userName"
          label="用户姓名"
          min-width="8%"
        >
        </el-table-column>
        <el-table-column
          prop="roleName"
          label="所属角色"
          min-width="8%"
        >
        </el-table-column>
        <el-table-column
          prop="operationName"
          label="操作"
          min-width="6%"
        >
        </el-table-column>
        <el-table-column
          prop="logMessage"
          label="日志信息"
          min-width="30%"
        >
        </el-table-column>
        <el-table-column
          prop="objMessage"
          label="操作对象"
          min-width="30%"
        >
        </el-table-column>
        <el-table-column
          prop="module"
          label="所属模块"
          min-width="8%"
        >
        </el-table-column>
        <el-table-column
          prop="creatDateTime"
          label="开始时间"
          min-width="16%"
        >
          <template slot-scope="scope">
            {{formatDateTime(scope.row.creatDateTime)}}
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.pagnum"
        :page-sizes="[5,10, 20, 50]"
        :page-size="queryInfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
      </div>
    </el-card>
  </div>
</template>

<script>
  export default {
    name: 'riZhiList',
    data(){
      return{
        riZhiData:[],
        queryInfo:{
          userName:'',
          operationName:'',
          pageNumber:1,
          pageSize:10,
        },
        total:0,
        options: [{
          value: '查询',
          label: '查询'
        }, {
          value: '保存',
          label: '保存'
        }, {
          value: '修改',
          label: '修改'
        }, {
          value: '删除',
          label: '删除'
        }, {
          value: '登录',
          label: '登录'
        },{
          value: '退出',
          label: '退出'
        },{
          value: '异常',
          label: '异常'
        }],
      }
    },
    created () {
      this.getRiZhiList()
    },
    methods:{
      async getRiZhiList(){
        const {data:res}=await  this.$http3.get('/v1.0/systemLog/findPages',{
          params:this.queryInfo
        })
        if(res.status!=="3000"){
          return this.$message.error('获取日志列表失败！'+res.message)
        }
        this.riZhiData=res.data.result;
        this.total=res.data.totalCount;
      },
      handleSizeChange(newSize){
        this.queryInfo.pageSize=newSize;
        this.getRiZhiList()
      },
      handleCurrentChange(newPage){
        this.queryInfo.pageNumber=newPage;
        this.getRiZhiList()
      },
      formatDateTime(date){
        let d = new Date(date);
        let month = (d.getMonth() + 1) < 10 ? '0'+(d.getMonth() + 1) : (d.getMonth() + 1);
        let day = d.getDate()<10 ? '0'+d.getDate() : d.getDate();
        let hours = d.getHours()<10 ? '0'+d.getHours() : d.getHours();
        let min = d.getMinutes()<10 ? '0'+d.getMinutes() : d.getMinutes();
        let sec = d.getSeconds()<10 ? '0'+d.getSeconds() : d.getSeconds();
        let times=d.getFullYear() + '-' + month + '-' + day + ' ' + hours + ':' + min + ':' + sec;
        return times
      },

    }
  }
</script>

<style scoped lang="less">
  #rzList{
    position: absolute;
    left: 15.5%;
    top: 9.5%;
    bottom: 1.5%;
    width: 83.5%;
    /*background-color: #ffffff;*/
    border-radius: 8px;
    box-shadow: 0 0 5px #acc4fe;
  }
  ::v-deep .cell{
    text-align: center;
  }
  .el-row{
    ::v-deep  .el-input__inner{
      border-radius: 45px;
    }
    ::v-deep .el-button:focus, .el-button:hover {
      color: #fff;
      border-color: #c6e2ff;
      background: -webkit-linear-gradient(left,#3ee8c2,#25e4a3);
    }
    ::v-deep .el-button--goon:active {
      color: #fff;
      border-color: #c6e2ff;
      outline: 0;
    }
  }

  /deep/ .el-input-group__append{
    border-radius: 45px;
  }
  .el-row{
    ::v-deep  .el-input__inner{
      border-radius: 45px;
    }

  }
  /deep/ .el-table th.gutter{
    display: table-cell!important;
  }

  .ziYuanTable{
    position: absolute;
    width: 97%;
    padding: 0%;
    /*height: 100%;*/
    height: calc(100% - 140px);
  }
  /deep/ .cell{
    text-align: center;
  }
  /deep/ .el-table__empty-text{
    line-height:44px
  }
  /deep/ .el-table__empty-block{
    min-height: 44px;
  }
  /deep/ .el-table__body-wrapper {
    /*height: 200px; !* 滚动条整体高 必须项 *!*/
    border-right: none;
    overflow-y: scroll;/* overflow-y为了不出现水平滚动条*/
  }
  /deep/ .el-dialog--center .el-dialog__body{
    padding: 10px;
  }
  /deep/ .el-table__body-wrapper::-webkit-scrollbar {
    width:6px;/* 滚动条的宽高 必须项 */
    height: 5px;
  }

  /deep/ .el-table__body-wrapper::-webkit-scrollbar-thumb {
    background-color: #bfcbd9;/* 滚动条的宽 */
    border-radius: 3px;
  }
</style>
